<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->

<link href="/Public/Admin/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="/Public/Admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/Public/Admin/static/h-ui.admin/skin/default/skin.css" id="skin" />

<script type="text/javascript" src="/Public/Admin/lib/jquery/1.9.1/jquery.min.js"></script> 

<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title></title>
<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
	
<link rel="stylesheet" href='/Public/Admin/css/caidanEdit.css'/>
<div id="content">
<?php if(empty($id)): ?><p>请在右侧选择菜单</p><?php endif; ?>
<?php if($haveSub == 1): ?><div class="bg">
		<div class="nav">
			<span id="title"><?php echo ($caidan['name']); ?></span>
			<a href="javascript:" onclick="caidanDel(1,'<?php echo U("caidanDel",array('id'=>$id));?>')">删除菜单</a>
		</div>
		<p>已添加子菜单，仅可设置菜单名称。</p>
		<form action="" method="post" class="form form-horizontal" id="form-member-add">
			<div class="row cl">
				<label class="form-label col-xs-3"><span class="c-red">*</span>菜单名称：</label>
				<div class="formControls col-xs-7">
					<input type="text" class="input-text radius" value="<?php echo ($caidan['name']); ?>" placeholder="" name="name">
				</div>
			</div>
			<input type="hidden" name='id' value="<?php echo ($id); ?>"/>
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
		</form>
	</div><?php endif; ?>
<?php if($haveSub == 2): ?><div class="bg">
		<div class="nav">
			<span id="title"><?php echo ($caidan['name']); ?></span>
			<a href="javascript:" onclick="caidanDel(0,'<?php echo U("caidanDel",array('id'=>$id));?>')">删除子菜单</a>
		</div>
		<form action="" method="post" class="form form-horizontal" id="form-member-add">
			<div class="row cl">
				<label class="form-label col-xs-3"><span class="c-red">*</span>菜单名称：</label>
				<div class="formControls col-xs-7">
					<input type="text" class="input-text radius" value="<?php echo ($caidan['name']); ?>" placeholder="" name="name">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3"><span class="c-red">*</span>菜单内容：</label>
				<div class="formControls col-xs-7 skin-minimal">
				  <div class="radio-box" onclick="sendMessage()" id="msg">
			          <input type="radio" id="sex-1" name="type" value="1" <?php if($caidan['type'] == 1): ?>checked<?php endif; ?>>
			          <label onclick="sendMessage()" for="sex-1">发送消息</label>
			        </div>
			        <div class="radio-box" onclick="setUrl()" onclick="setUrl()" id="url">
			          <input type="radio" id="sex-2" name="type" value="2" <?php if($caidan['type'] == 2): ?>checked<?php endif; ?>>
			          <label for="sex-2" onclick="setUrl()">跳转网页</label>
			        </div>
				</div>
			</div>
			<div class="row cl msg_con <?php if($caidan['type'] == 2): ?>hidden<?php endif; ?>">
		      <label class="form-label col-xs-3">消息内容：</label>
		      <div class="formControls col-xs-7">
		        <textarea name="content" cols="" rows="" class="textarea" ><?php echo ($caidan['content']); ?></textarea> 
		      </div>
		    </div>
		    <div class="row cl url_con <?php if($caidan['type'] == 1): ?>hidden<?php endif; ?>">
		      <label class="form-label col-xs-3">链接地址：</label>
		      <div class="formControls col-xs-7">
		        <input type="text" class="input-text radius" value="<?php echo ($caidan['url']); ?>" placeholder="" name='url'>
		      </div>
		    </div>
		    <input type="hidden" name='id' value="<?php echo ($id); ?>"/>
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
		</form>
	</div><?php endif; ?>
</div>
<script>
function caidanDel(type,url){
	var msg = '';
	if(type == 1){
		msg = '删除彩菜单会把子菜单一起删除';
	}else{
		msg = '确定删除子菜单';
	}
	var index = layer.confirm(msg, {
		  btn: ['确定','取消'] //按钮
		}, function(){
		  layer.close(index);
		  $.get(url,function(res){
			  if(res == 1){
				  layer.msg('删除成功',{icon:6,time:1000});
				  setTimeout(function(){
					  parent.location.reload();
				  },1000);
			  }else{
				  layer.msg('删除失败',{icon:5,time:1000});
			  }
		  })
		});
}
function sendMessage(){
	$('.msg_con').removeClass('hidden');
	$('.url_con').addClass('hidden');
}
function setUrl(){
	$('.url_con').removeClass('hidden');
	$('.msg_con').addClass('hidden');
}
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	$('#msg').find('.iradio-blue').attr('onclick','sendMessage()');
	$('#url').find('.iradio-blue').click('setUrl');
	
	$("#form-member-add").validate({
		rules:{
			name:{
				required:true,
				minlength:2,
				maxlength:16
			},
			
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
	        	type: 'post', // 提交方式 get/post
	            url: '<?php echo U("caidanEdit");?>', // 需要提交的 url
	            success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
	            	if(data.status == 1){
	            		layer.msg('修改成功',{icon:6,time:1000});
	            		$(parent.document).find('.on').text(data.name);
	            		$('#title').text(data.name);
	            	}else{
	            		layer.msg(data.msg,{icon:5,time:1000});
	            	}
	            }
	        });
		}
	});
});
</script>

	
<script type="text/javascript" src="/Public/Admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/Public/Admin/static/h-ui.admin/js/H-ui.admin.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>

<script type="text/javascript" src="/Public/Admin/lib/webuploader/0.1.5/webuploader.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/ueditor/1.4.3/ueditor.config.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/ueditor/1.4.3/ueditor.all.min.js"> </script> 
<script type="text/javascript" src="/Public/Admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
</body>
</html>